/**
 * 下单的主界面
 */
Page({

  /**
   * 页面的初始数据
   */
  data: {
    fromAddress: null, // 发货地址信息
    fromPerson: null, // 发货人信息
    toAddress: null, // 收货地址信息
    toPerson: null, // 收货人信息
    goodsName: '', // 货物名称
    goodsWeight: '', // 货物重量
    goodsVolume: '', // 货物体积
    goodsCnt: '', // 货物件数
    pickUpFee: 4000, // 取货费
    sendFee: 5000, // 送货费
    items_pickUp: [ // 取货类型
      { name: 4000, value: '是', checked: 'true' },
      { name: 0, value: '否' },
    ],
    items_send: [ // 送货类型
      { name: 5000, value: '是', checked: 'true' },
      { name: 0, value: '否' },
    ],

    // // < fromAddress toAddress >数据示例
    // fromAddress: {//发货地
    //   province: { name: "北京市", code: "" },
    //   city: { name: "北京市", code: "" },
    //   area: { name: "大兴区", code: "" },
    //   address: "大兴黄亦路128号",
    //   oddAddress: "奥宇科技英巢",
    //   gps_lat: 0,
    //   gps_lon: 0,
    // },
    // // < fromPerson toPerson >数据示例
    // fromPerson: { person: "发货人", phone: "18537759676" },
  },

  /**
   * 点击编辑发货信息
   */
  click_toEditFromInfo: function (e) {
    wx.navigateTo({
      url: '../edit_address_info/edit_address_info?whichPage=1'
    });
  },

  /**
   * 点击编辑收货信息
   */
  click_toEditToInfo: function (e) {
    wx.navigateTo({
      url: '../edit_address_info/edit_address_info?whichPage=2'
    });
  },

  /**
   * 货物名称的输入
   */
  input_goodsName: function (e) {
    this.setData({
      goodsName: e.detail.value,
    });
  },

  /**
    * 货物重量的输入
    */
  input_goodsWeight: function (e) {
    this.setData({
      goodsWeight: e.detail.value,
    });
  },

  /**
    * 货物体积的输入
    */
  input_goodsVolume: function (e) {
    this.setData({
      goodsVolume: e.detail.value,
    });
  },

  /**
    * 货物件数的输入
    */
  input_goodsCnt: function (e) {
    this.setData({
      goodsCnt: e.detail.value,
    });
  },

  /**
   * 确认按钮
   */
  click_confirm: function (e) {
    var that = this;

    var fromAddress = that.data.fromAddress;
    var fromPerson = that.data.fromPerson;
    var toAddress = that.data.toAddress;
    var toPerson = that.data.toPerson;
    var goodsName = that.data.goodsName;
    var goodsWeight = that.data.goodsWeight;
    var goodsVolume = that.data.goodsVolume;
    var goodsCnt = that.data.goodsCnt;
    if (null == fromAddress ||
      null == fromPerson ||
      null == toAddress ||
      null == toPerson ||
      '' == goodsName ||
      '' == goodsWeight ||
      '' == goodsVolume ||
      '' == goodsCnt) {
      wx.showToast({
        title: '请完善信息',
        image: '../../../images/warn.png',
        duration: 2000
      });
    }

  },

  /**
   * 上门取货的选择
   */
  change_pickUp: function (e) {
    var that = this;
    that.setData({
      pickUpFee: e.detail.value,
    });
  },

  /**
  * 派哥送货的选择
  */
  change_send: function (e) {
    var that = this;
    that.setData({
      sendFee: e.detail.value,
    });
  },
})